package com.tyl.xtk.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tyl.xtk.beans.po.Permission;
import com.tyl.xtk.beans.po.Role;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * create by tyl at 2025/8/27
 */
public interface RoleMapper extends BaseMapper<Role> {
    @Select("select r.* from user_role_map m left join role_info r on m.role_id = r.id where m.user_id = #{userId}")
    List<Role> selectByUserId(@Param("userId") long userId);
    
    @Select("select p.* from permission_info p " +
            "left join role_permission_map rpm on p.id = rpm.permission_id " +
            "where rpm.role_id = #{roleId}")
    List<Permission> selectByRoleId(@Param("roleId") long roleId);
}